package com.zjt.controller;

import com.zjt.bean.BaseRespVo;
import com.zjt.bean.Info;
import com.zjt.bean.LoginUser;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
public class AuthController {

    @RequestMapping("admin/auth/login")
    public BaseRespVo login(@RequestBody LoginUser user){//@RequestBody意味着接收Json
        //login的data → 字符串 → sessionid
        //登录信息是放在session中的 → sessionId给到前端了
        //跨域 → session发生变化
        //Shiro → 权限管理框架 → 视频课程

        //不全Shiro代码

        return BaseRespVo.ok("c05d7a95-987e-4739-813e-b2a9242c12f9");
    }

    @RequestMapping("admin/auth/info")
    public BaseRespVo info(String token) {
        //业务补全 → 数据通过service业务处理

        Info info = new Info();
        info.setAvatar("https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        info.setName("songge");
        ArrayList<String> perms = new ArrayList<>();
        perms.add("*");
        info.setPerms(perms);
        ArrayList<String> roles = new ArrayList<>();
        roles.add("超级管理员");
        info.setRoles(roles);

        return BaseRespVo.ok(info);
    }
}
